package com.chw.admin.employee;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chw.admin.customer.ChwCustomer;
import com.chw.annotation.PermissionSecurity;
import com.chw.common.ServiceData;
import com.chw.utils.LogUtil;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;

@Controller
@RequestMapping({ "/chwEmployee" })
public class ChwEmployeeController {
	private static LogUtil log = LogUtil.newInstance(ChwEmployeeController.class);

	@Autowired
	private IChwEmployeeService chwEmployeeService;

	@RequestMapping(value = { "/findEntity.do" }, method = {
			org.springframework.web.bind.annotation.RequestMethod.POST }, consumes = {
					"*/*" }, produces = { "application/json" })
	@ResponseBody
	@PermissionSecurity(name = "查询", module = "人员管理", btnfunc = "CHW_EMPLOYEE")
	public ServiceData findEntity(HttpServletRequest request, ChwEmployee chwEmployee, Integer currentPage,
			Integer pageSize) throws Exception {
		ServiceData ret = new ServiceData();
		PageInfo chw = this.chwEmployeeService.findByEntity(chwEmployee, currentPage, pageSize);
		ret.setCode(request, ServiceData.RetCode.Success);
		ret.setBo(chw);
		return ret;
	}
	
	@RequestMapping(value={"/saveChwEmployee.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
	/*    */   @ResponseBody
	/*    */   @PermissionSecurity(name="新增", module="新增人员管理", btnfunc="add_CHW_EMPLOYEE")
	/*    */   public ServiceData add(HttpServletRequest request, String param) throws Exception {
	/* 45 */     ServiceData ret = new ServiceData();
	/* 46 */     Gson gson = new Gson();
	/* 47 */     ChwEmployee chwCustomer = (ChwEmployee)gson.fromJson(param, ChwEmployee.class);
	/*    */ 
	/* 49 */     int i = this.chwEmployeeService.save(chwCustomer);
	/* 50 */     ret.setCode(request, ServiceData.RetCode.Success);
	/* 51 */     ret.setBo(Integer.valueOf(i));
	/* 52 */     return ret;
	/*    */   }
	
	@RequestMapping(value={"/delChwEmployee.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
	/*    */   @ResponseBody
	/*    */   @PermissionSecurity(name="删除", module="删除客户管理", btnfunc="del_chw_employee")
	/*    */   public ServiceData del(HttpServletRequest request, String id, HttpServletResponse response) throws Exception {
	/* 75 */     ServiceData ret = new ServiceData();
	/*    */ 
	/* 77 */     int i = this.chwEmployeeService.delEmployee(id);
	/* 78 */     ret.setCode(request, ServiceData.RetCode.Success);
	/* 79 */     ret.setBo(Integer.valueOf(i));
	/* 80 */     return ret;
	/*    */   }
	 @RequestMapping(value={"/findChwCustomerById.notPermSc"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
	 /*    */   @ResponseBody
	 /*    */   public ServiceData findById(HttpServletRequest request, String id) throws Exception {
	 /* 87 */     ServiceData ret = new ServiceData();
	 /*    */ 
	 /* 89 */     ChwEmployee rta = this.chwEmployeeService.findById(id);
	 /* 90 */     ret.setCode(request, ServiceData.RetCode.Success);
	 /* 91 */     ret.setBo(rta);
	 /* 92 */     return ret;
	 /*    */   }
	 
	 @RequestMapping(value={"/updateChwEmployee.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
	 /*    */   @ResponseBody
	 /*    */   @PermissionSecurity(name="修改", module="修改人员管理", btnfunc="update_Customer")
	 /*    */   public ServiceData update(HttpServletRequest request, String param) throws Exception { ServiceData ret = new ServiceData();
	 /* 61 */     Gson gson = new Gson();
	 /* 62 */     ChwEmployee chwCustomer = (ChwEmployee)gson.fromJson(param, ChwEmployee.class);
	 /*    */ 
	 /* 64 */     int i = this.chwEmployeeService.update(chwCustomer);
	 /* 65 */     ret.setCode(request, ServiceData.RetCode.Success);
	 /* 66 */     ret.setBo(Integer.valueOf(i));
	 /* 67 */     return ret; } 
}
